angular.module('registerModule', [])
.controller('registerCtrl', ['$scope','$http','$location', function ($scope,$http,$location) {
    $scope.submit = function(){
        console.log($scope.username+','+$scope.password);
        $http.post('./admin/register.php',{
            postType:'register',
            username:$scope.username,
            password:$scope.password
        }).then(function(res){
            console.log(res.data);
            if(res.data.status == 1){
                var go = confirm("注册成功！是否立即登录？");
                if(go){
                    $location.path('/login');
                }
            }else{
                if(res.data.status == 2){
                    alert('该账号已被注册!');
                }else{
                    alert('注册失败');
                }
            }
        });
        
    }
}])